﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace DevDemo.ProgressBarControlDemo
{
    public partial class ProgressBarControlDemo1 : DevExpress.XtraEditors.XtraForm
    {
        public ProgressBarControlDemo1()
        {
            InitializeComponent();
        }

        private void ProgressBarControlDemo1_Load(object sender, EventArgs e)
        {
            //水平进度条
            progressBarControl1.Properties.Minimum = 0;
            progressBarControl1.Properties.Maximum = 100;
            progressBarControl1.Properties.Step = 1;
            progressBarControl1.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
            progressBarControl1.Position = 0;
            progressBarControl1.Properties.ShowTitle = true;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.ProgressKind = DevExpress.XtraEditors.Controls.ProgressKind.Horizontal;

            //垂直进度条
            progressBarControl2.Properties.Minimum = 0;
            progressBarControl2.Properties.Maximum = 100;
            progressBarControl2.Properties.Step = 1;
            progressBarControl2.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
            progressBarControl2.Position = 0;
            progressBarControl2.Properties.ShowTitle = true;
            progressBarControl2.Properties.PercentView = true;
            progressBarControl2.Properties.ProgressKind = DevExpress.XtraEditors.Controls.ProgressKind.Vertical;
            progressBarControl2.Properties.TextOrientation = DevExpress.Utils.Drawing.TextOrientation.VerticalUpwards;

            marqueeProgressBarControl1.Properties.ProgressKind = DevExpress.XtraEditors.Controls.ProgressKind.Horizontal;
            marqueeProgressBarControl1.Properties.ShowTitle = true;
            marqueeProgressBarControl1.Text = "横向读取数据中，请稍等。。。。";

            marqueeProgressBarControl2.Properties.ProgressKind = DevExpress.XtraEditors.Controls.ProgressKind.Vertical;
            marqueeProgressBarControl2.Properties.ShowTitle = true;
            marqueeProgressBarControl2.Text = "纵向数据读取中，请稍等";
            marqueeProgressBarControl2.Properties.TextOrientation = DevExpress.Utils.Drawing.TextOrientation.VerticalUpwards;
        }

        /// <summary>
        /// Test
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 100; i++)
            {
                System.Threading.Thread.Sleep(120);
                progressBarControl1.PerformStep();
                progressBarControl2.PerformStep();
                //progressBarControl1.Position += 1;
                progressBarControl2.EditValue = i + 1;
                //progressBarControl1.Position += 1;
                progressBarControl2.EditValue = i + 1;

                //处理当前消息队列中的所有windows消息,不然进度条会不同步
                Application.DoEvents();
            }
            progressBarControl1.EditValue = 0;
            progressBarControl2.EditValue = 0;
        }
    }
}